package com.hdu.point_offer;

public class lcr140 {


    public class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

    class Solution {
        public ListNode trainingPlan(ListNode head, int cnt) {
            int len = 0;
            ListNode cur = head;
            while (cur != null) {
                len++;
                cur = cur.next;
            }
            int index = len - cnt;
            cur = head;
            while (index > 0) {
                cur = cur.next;
                index--;
            }
            return cur;
        }
    }
}
